package cn.edu.ctbu.datajpacrud.api;

import cn.edu.ctbu.datajpacrud.VO.R;
import cn.edu.ctbu.datajpacrud.domain.Teacher;
import cn.edu.ctbu.datajpacrud.helper.RUtil;
import cn.edu.ctbu.datajpacrud.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/login")
public class LoginApiController {

    @Autowired
    private TeacherService teacherService;


    @GetMapping("/teacher")
    public R student(String name, String password) throws Exception {

        Teacher teacher = teacherService.findByNameAndPassword(name, password);
        return RUtil.success(teacher);
    }
}